

#data=(12,2.3)
#data1=[12,2.3,'re', [12,33], {'a':23, 'b':23.4, 'c':[12,32]}]
#data2={'a':12,'b':2.3,'c':'re'}
def list2Json(data):
  resstr="["
  for i in data:
    tmp=""
    if type(i) is int:
      tmp = "'%d'" % (i)
    if type(i) is float:
      tmp = "'%.2f'" % (i)
    if type(i) is str:
      tmp = "'%s'" % (i) 
    if type(i) is list or type(i) is tuple:
      tmp = list2Json(i) 
    if type(i) is dict:
      tmp = dict2Json(i)

    resstr +=  tmp + ","   
  resstr = resstr[:-1] + "]"
  return resstr

def dict2Json(data):
  resstr="{"
  for i in data:
    tmp=""
    if type(data[i]) is int:
      tmp = "'%d'" % (data[i])
    if type(data[i]) is float:
      tmp = "'%.2f'" % (data[i])
    if type(data[i]) is str:
      tmp = "'%s'" % (data[i]) 
    if type(data[i]) is list or type(data[i]) is tuple:
      tmp = list2Json(data[i]) 
    if type(data[i]) is dict:
      tmp = dict2Json(data[i])

    resstr +=  "'" + i + "':" + tmp + ","   
  resstr = resstr[:-1] + "}"
  return resstr

def toJson(data):
  if type(data) is dict:
    return dict2Json(data)
  elif type(data) is list or type(data) is tuple:
    return list2Json(data)
  else:
    print "err"
    return ""
#print toJson(data1) 
